Module Definition (.def) File

The last element of your UFL is the module definition (.def) file. This is just like any module definition file you would create for a DLL, but you must make sure to explicitly export not only your UFL function, but also the specialized UFL functions defined in UFMAIN.C that Crystal Reports expects to find. The following is an example of a module definition file for the UFL that exports the Picture function (seePicture Function - a sample UFL function):

Library        UFLSAMP
Description        'User Function Library for Crystal Reports'
ExeType        Windows
HeapSize        1024
Code            Moveable Discardable Preload
Data            Moveable Preload
Segments        _TEXT    Preload

Exports
            WEP
            UFINITIALIZE
            UFTERMINATE
            UFGETVERSION
            UFSTARTJOB
            UFENDJOB
            UFGETFUNCTIONDEFSTRINGS
            UFGETFUNCTIONEXAMPLES
            UFGETFUNCTIONTEMPLATES
            UFERRORRECOVERY
            PICTURE

Notice that the only function exported that you actually coded is the Picture UFL. The rest of the exported functions have been defined for you in UFMAIN.C. Every UFL must export these 9 UF* functions. In addition to these functions, every UFL that you create must be exported.

Note:    If you are creating a 32-bit UFL, do not export the WEP procedure function. If you are creating a 32-bit UFL, you will only need to include the LIBRARY, DESCRIPTION, and EXPORTS sections of the .def file.

When you have finished coding the module definition file, save it to your working directory and add it to the list of files in your project file.

Finally, compile and link the ufl* or u2l* project file. Resolve any errors that occur, and recompile if necessary. Once you have your DLL (ufl*.dll or u2l*.dll), place it in the directory that holds CRW.EXE. From that point on, when you open the Formula Editor, your User-Defined Function(s) will appear in the "Additional Functions" section at the bottom of the Functions list of the Formula Editor. Enter each function in one or more formulas, and test and modify it until it works the way you want.

Note:    For additional information, review UFLSAMP1.C and UFLSAMP2.C (sample files that were installed in the Crystal Reports directory, \CRW, by default).



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com